from modules.Chinese_Chinese.Chinese_Chineseoption import Chinese_ChineseOption
from common.iniconfig import iniconfig
import wx
import gettext

class dict_Chinese_Chineseoption(Chinese_ChineseOption):
	
        def __init__(self,parent):
                Chinese_ChineseOption.__init__(self,parent)
                self.Bind( wx.EVT_INIT_DIALOG, self.OnInitDialog )
		self.m_Ok.Bind( wx.EVT_BUTTON, self.OnOk )
		self.m_Cancel.Bind( wx.EVT_BUTTON, self.OnCancel )
		self.m_Apply.Bind( wx.EVT_BUTTON, self.OnApply )
		self.m_Ok.SetDefault()
		
        
	def OnInitDialog( self, event ):
		self.m_auto_save.Append(_("True"))
		self.m_auto_save.Append(_("False"))
		a=iniconfig("modules/Chinese_Chinese/settings")
		if a.get_item("auto_save")=="1":
			self.m_auto_save.SetValue(_("True"))
		else:
			self.m_auto_save.SetValue(_("False"))
		
	def OnOk( self, event ):
		a=iniconfig("modules/Chinese_Chinese/settings")
		if self.m_auto_save.GetValue().strip()==_("True"):
			a.set_item("auto_save","1")
		else:
			a.set_item("auto_save","0")
		self.Close()
			
	def OnCancel( self, event ):
		self.Close()
			
	def OnApply( self, event ):
		a=iniconfig("modules/Chinese_Chinese/settings")
		if self.m_auto_save.GetValue().strip()==_("True"):
			a.set_item("auto_save","1")
		else:
			a.set_item("auto_save","0")